<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
	<title></title>
</head>
<body>
    <form onsubmit="return allSelected();">
       首重<select id="sel1">
        <option value="0">选择价格</option>
        <option value="8" >广东8元</option>
        <option value="10" >江苏10元</option>
        <option value="10" >浙江10元</option>
        <option value="10" >上海10元</option>
        <option value="12" >安徽12元</option>
        <option value="12" >北京12元</option>
      </select>
      续价
      <select id="sel2">
        <option value="0">选择续价</option>
        <option value="1" >广东1元</option>
        <option value="5" >江苏5元</option>
        <option value="5" >浙江5元</option>
        <option value="5" >上海5元</option>
        <option value="5" >安徽5元</option>
        <option value="5" >北京5元</option>
      </select>
      续重<input id="sel3" size="5" value="0" onFocus="if (value =='0'){value =''}" onBlur="if (value ==''){value='0'}" title="输入续重重量,不含首重!" />
      运费:<input id="sum" size="5" style="border:0;background:transparent;width:30px;height:15px;color:#FF0000" title="最终计费" />元(首重+续重费用*重量)

      <script type="text/javascript">
  <!--
    window.onload = function(){
        for(var i=1;i<=3;i++){
            document.forms[0]["sel" + i].onchange = getSum; //当菜单的value发生改变时，执行getSum函数
        }
    }
	function getSum(){
	  if(this.nodeName=='SELECT'){
	   var index = this.selectedIndex
	   document.getElementById("sel1").options[index].selected = true; // 表单的选项为选中状态
	   document.getElementById("sel2").options[index].selected = true;
	  }
	        var sum = 0;
	        var val1=parseFloat(document.getElementById("sel1").value);
	        var val2=parseFloat(document.getElementById("sel2").value);
	        var val3=parseFloat(document.getElementById("sel3").value);
	        sum=val1+val2*val3;
	        document.getElementById('sum').value = sum;
	    }
	    function allSelected(){
	        for(var i=1;i<=3;i++){
	            if(document.getElementById("sel" + i).value == 0){
	                alert('请为所有项目选择！');
	                return false;
	            }
	        }
	        return true;
	    }
  //-->
  </script>
    </form>
</body>

</html>